/* Copyright (c) 2004-2024 peigen.info. All rights reserved. */

package info.peigen.hotpot.business.customer.manage.repository.mapper;

import info.peigen.hotpot.business.customer.core.repository.entity.CustomerEntity;
import info.peigen.hotpot.component.data.repository.beetlsql.mapper.AbstractBeetlSqlManageMapper;
import org.beetl.sql.mapper.annotation.Select;
import org.beetl.sql.mapper.annotation.Sql;
import org.beetl.sql.mapper.annotation.Update;

/**
 * <b>(CustomerManageMapper)</b>
 * 管理后台 "客户" 数据库映射服务
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023-09-09
 */
@SuppressWarnings("unused")
public interface CustomerManageMapper extends AbstractBeetlSqlManageMapper<CustomerEntity> {

    // 唯一索引[customer_id]
    @Sql("select * from customer where customer_id = ?")
    @Select
    CustomerEntity findByCustomerId(String customerId);

    @Sql("select * from customer where customer_id = ? for update")
    @Select
    CustomerEntity lockByCustomerId(String customerId);

    @Sql("delete from customer where customer_id = ?")
    @Update
    void deleteByCustomerId(String customerId);

    // 索引[status]
    @Sql("select * from customer where status = ?")
    @Select
    CustomerEntity findByStatus(String status);

    @Sql("delete from customer where status = ?")
    @Update
    void deleteByStatus(String status);

    // 唯一索引[mobile]
    @Sql("select * from customer where mobile = ?")
    @Select
    CustomerEntity findByMobile(String mobile);

    @Sql("select * from customer where mobile = ? for update")
    @Select
    CustomerEntity lockByMobile(String mobile);

    @Sql("delete from customer where mobile = ?")
    @Update
    void deleteByMobile(String mobile);

    // 索引[proxy_id]
    @Sql("select * from customer where proxy_id = ?")
    @Select
    CustomerEntity findByProxyId(String proxyId);

    @Sql("delete from customer where proxy_id = ?")
    @Update
    void deleteByProxyId(String proxyId);

    // 索引[sales_id]
    @Sql("select * from customer where sales_id = ?")
    @Select
    CustomerEntity findBySalesId(String salesId);

    @Sql("delete from customer where sales_id = ?")
    @Update
    void deleteBySalesId(String salesId);

    // 索引[customer_service_id]
    @Sql("select * from customer where customer_service_id = ?")
    @Select
    CustomerEntity findByCustomerServiceId(String customerServiceId);

    @Sql("delete from customer where customer_service_id = ?")
    @Update
    void deleteByCustomerServiceId(String customerServiceId);

    // 索引[partner_id]
    @Sql("select * from customer where partner_id = ?")
    @Select
    CustomerEntity findByPartnerId(String partnerId);

    @Sql("delete from customer where partner_id = ?")
    @Update
    void deleteByPartnerId(String partnerId);
}